# -*- coding: utf-8 -*-
# @Time : 2021/9/17 15:50
# @Author : jiangping
# @Email : jp@gmail.com
# @File : MRYX_SPFL_003.py
# @Project : mryx_test
"""通过商品分类-价格从低到高排列"""

from time import sleep
from appium.webdriver.common.mobileby import MobileBy as By
from appium import webdriver

desired_capabilities = {
    'platformName':'Android',
    'deviceName':'127.0.0.1:62001',
    'platformVersion':'7.1.2',
    'appPackage':'cn.missfresh.application',
    'appActivity':'cn.missfresh.module.main.view.SplashActivity',
    'noReset':True
}
driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_capabilities)
sleep(2)
#定位器
#首页
goods_sort_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().text("分类")')#首页分类
#分类页
recommend_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().text("推荐")')#推荐
#推荐商品页
price_locator = (By.ID,'cn.missfresh.application:id/tv_price')#价格
goodprice_locator = (By.ID,'cn.missfresh.application:id/tv_common_price')

#1、点击分类
goods_sort_element = driver.find_element(*goods_sort_locator).click()
sleep(2)
#2、点击推荐
recommend_element = driver.find_element(*recommend_locator).click()
sleep(2)
#3、点击【价格】
price_element = driver.find_element(*price_locator).click()
sleep(2)
#断言-判断价格从低到高
price_list_ = driver.find_elements(*goodprice_locator)
sleep(3)
driver.quit()